package com.qingke.oms.command.user;

import com.qingke.oms.command.UserCommand;
import com.qingke.oms.pojo.Recharge;
import com.qingke.oms.pojo.User;
import com.qingke.oms.util.OMSConsole;

public class RechargeCommand extends UserCommand {

	public RechargeCommand(User user) {
		super(user);
	}

	@Override
	public void execute() {
		OMSConsole.println("Please input how much you want to recharge.");
		double money=OMSConsole.getDouble("money>");
		Recharge recharge=new Recharge();
		recharge.setAmount(money);
		recharge.setUser(user);
		dao.clear();
		boolean isSuccess=dao.createRecharge(recharge);
		user=dao.selectNewestUserById(user.getId());
		if(isSuccess)
			OMSConsole.println("Recharge success.");
		else
			OMSConsole.println("Recharge failed.");
		
	}

}
